home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / python-support / python-rdflib / rdflib / exceptions.py < prev    next >
Encoding:
Python Source  |  2007-04-04  |  2.0 KB  |  64 lines

  1.  
  2. class Error(Exception):
  3.     """Base class for rdflib exceptions."""
  4.     def __init__(self, msg=None):
  5.         Exception.__init__(self, msg)
  6.         self.msg = msg
  7.  
  8.  
  9. class TypeCheckError(Error):
  10.     """Parts of assertions are subject to type checks."""
  11.  
  12.     def __init__(self, node):
  13.         Error.__init__(self, node)
  14.         self.type = type(node)
  15.         self.node = node
  16.  
  17.  
  18. class SubjectTypeError(TypeCheckError):
  19.     """Subject of an assertion must be an instance of URIRef."""
  20.     def __init__(self, node):
  21.         TypeCheckError.__init__(self, node)
  22.         self.msg = "Subject must be instance of URIRef or BNode: %s(%s)" \
  23.                        % (self.node, self.type)
  24.  
  25.  
  26. class PredicateTypeError(TypeCheckError):
  27.     """Predicate of an assertion must be an instance of URIRef."""
  28.     def __init__(self, node):
  29.         TypeCheckError.__init__(self, node)
  30.         self.msg = "Predicate must be a URIRef instance: %s(%s)" \
  31.                        % (self.node, self.type)
  32.  
  33.  
  34. class ObjectTypeError(TypeCheckError):
  35.     """Object of an assertion must be an instance of URIRef, Literal,
  36.     or BNode."""
  37.     def __init__(self, node):
  38.         TypeCheckError.__init__(self, node)
  39.         self.msg = "Object must be instance of URIRef, Literal, or BNode: %s(%s)" % \
  40.                        (self.node, self.type)
  41.  
  42. class ContextTypeError(TypeCheckError):
  43.     """Context of an assertion must be an instance of URIRef."""
  44.     def __init__(self, node):
  45.         TypeCheckError.__init__(self, node)
  46.         self.msg = "Context must be instance of URIRef or BNode: %s(%s)" \
  47.                        % (self.node, self.type)
  48.  
  49. class ParserError(Error):
  50.     """RDF Parser error."""
  51.     def __init__(self, msg):
  52.         self.msg = msg
  53.  
  54.     def __str__(self):
  55.         return self.msg
  56.  
  57.  
  58. class UniquenessError(Error) :
  59.     """A uniqueness assumption was made in the context, and that is not true"""
  60.     def __init__(self, values):
  61.         Error.__init__(self, "Uniqueness assumption is not fulfilled. Multiple values are: %s" % values)
  62.  
  63.  
  64.